<?php

include "inc/head.php";

if($_POST['AName'] != '' && $_POST['APwd'] != '')
{
	if(Admin::login($_POST))
	{
		if($_POST['NAPwd'] != $_POST['RAPwd'] || !$_POST['NAPwd'])
			alert("请输入新密码");
		$Admin = new Admin(array("AName"=>$_POST['AName'],"PenName"=>$_POST['PenName'],"APwd"=>md5($_POST['NAPwd'])));
		if($Admin->update("Admin", "APwd,PenName", "AName"))
		{
			new ActionLog(array("LogType"=>"cpw_success","Action"=>"{$_POST[AName]}"));
			alert("修改密码成功","location","cpw.php");
		}
	}
	else
	{
		new ActionLog(array("LogType"=>"cpw_err","Action"=>"{$_POST[AName]},{$_POST[APwd]}"));
		alert("用户名或密码错","location","login.php");
	}
}

?>
<table width="90%" cellpadding="1" cellspacing="1" class="list-div">
	<tr>
		<th colspan="2" align="left" style="padding:0 0 0 10px;"> 修改密码</th>   
    </tr>
<form method=post>
<input type="hidden" name="AName" value='<?php echo $_SESSION['AName']; ?>'>
<tr><td>笔　　名</td><td><input type="text" name="PenName" value='<?php echo $currAdmin->PenName; ?>'></td></tr>
<tr><td>密　　码</td><td><input type="password" name="APwd" value=''></td></tr>
<tr><td>新 密 码</td><td><input type="password" name="NAPwd" value=''></td></tr>
<tr><td>确认密码</td><td><input type="password" name="RAPwd" value=''></td></tr>
<tr><td></td><td><input type=submit value='修改'></td></tr>
</form>
</table>

<?php
include 'inc/foot.php';

?>